package pagelib;

import org.openqa.selenium.WebDriver;
import pageobjects.LoginPagePO;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.security.PublicKey;
import java.util.Properties;

public class LoginPageLib extends LoginPagePO {
    /**
     * 定义构造方法,进行Drivver的传递
     *
     * @param driver
     */
    public LoginPageLib(WebDriver driver) {
        super(driver);
    }

    public void login() throws Exception {
        Properties prop = new Properties();

        //读取Globaldata配置文件的内容
        File file = new File("Configs/GlobalData.properties");
        if (file.exists())
            prop.load(new FileReader(file));
        else {
            System.out.println("配置文件不存在!");
            return;
        }
        String userName = prop.getProperty("userName");
        String passWord = prop.getProperty("passWord");
        userName().sendKeys(userName);
        passWord().sendKeys(passWord);
        submitBtn().click();
    }
}
